using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Data;
using System.Windows.Media;
using System.Collections.ObjectModel;

namespace sample
{    
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void addPerson_Click(object sender, RoutedEventArgs e)
        {
            People pp = this.Resources["MyFriends"] as People;
            if (pp!=null)
            {
                pp.Add(new Person("Calvin", "Chen", "Dix Hills"));
            }
        }

        private void editPerson_Click(object sender, RoutedEventArgs e)
        {
            People pp = this.Resources["MyFriends"] as People;
            for(int i=0; i<pp.Count; i++)
            {
                Person p = pp[i];
                if (p.FirstName.Equals("Calvin"))
                {
                    p.FirstName = "Crystal";
                }
            }
        }
    }

}
